<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="com.systop.core.dao.support.Page"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <%@include file="/common/taglibs.jsp"%>
  <title>中国校校通</title>
  <%@include file="/common/meta.jsp"%>
  <link href="${ctx}/pages/new/themes/main.css" rel="stylesheet" type="text/css" />
  <LINK href="${ctx}/styles/style.css" type='text/css' rel='stylesheet'>
</head>
<body>
<%@include file="/pages/new/index_top.jsp" %>
<%@include file="/pages/new/index_search.jsp" %>
<table width="1002" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <div style="width: 1000px;">
        <s:iterator value="#attr.page.data" var="book">
		  <div class="books">
			<div class="bkphoto">
			  <a href="${ctx}/book/view.do?model.id=${book.id}" target="_blank" title="${book.name}">
				<img width="100" height="130" src="${ctx}${book.coverPhoto}" onError="this.src='${ctx}/images/longtian/book_nophoto_big.gif'">
			  </a>
			</div>
			<div class="bookinfo">
				<a href="${ctx}/book/view.do?model.id=${book.id}" target="_blank" title="${book.name}">${book.name}</a>
			</div>
			<div class="bookinfo">作者：${book.author}</div>
			<div>
			  <img src="${ctx}/images/longtian/but_buy.jpg" border="0"/>
			  <img src="${ctx}/images/longtian/but_coll.jpg" border="0"/>
			</div>
		  </div>
	    </s:iterator>
      </div>
    </td>
  </tr>
</table>
<table width="1000" align="center">
  <tr><td align="right">
	<%
		Page p = (Page)request.getAttribute("page");
	%>
	<% if (p != null){ %>
	<div style="">
		<a href="${ctx}/search/index.do?pageSize=<%=p.getPageSize()%>&ec_p=1">首页</a>&nbsp;&nbsp;
		<% if (p.hasPreviousPage()){ %>
			<a href="${ctx}/search/index.do?pageSize=<%=p.getPageSize()%>&ec_p=<%=p.getPageNo()-1%>">上一页</a>
		<%}else{ %>
			<span class="disEnable">上一页</span>
		<%} %>&nbsp;&nbsp;
		<% if (p.getHasNextPage()){ %>
			<a href="${ctx}/search/index.do?pageSize=<%=p.getPageSize()%>&ec_p=<%=p.getPageNo()+1%>">下一页</a>
		<%}else{ %>
			<span class="disEnable">下一页</span>
		<%} %>&nbsp;&nbsp;
		<a href="${ctx}/search/index.do?pageSize=<%=p.getPageSize()%>&ec_p=<%=p.getPages()%>">尾页</a>&nbsp;&nbsp;
		第<span style="color:red;"><%=p.getPageNo()%></span>页/共<span style="color:red;"><%=p.getPages()%></span>页&nbsp;&nbsp;
		<input type="text" id="ec_p" name="ec_p" style="width:35px">
		<input type="button" style="width:30px" value="GO" onClick="goPage()">
	</div>
	<script type="text/javascript">
	  function goPage(){
		var pageNo = document.getElementById('ec_p').value;
		var pNo = <%=p.getPages()%>;
		if (!isNaN(pageNo)){
			if(pNo < pageNo){
				pageNo = pNo;
			}
			window.location.href = "${ctx}/search/index.do?pageSize=<%=p.getPageSize()%>&ec_p=" + pageNo;
		}else{
			alert("请输入正确的数字!");
		}
	  }
	  window.parent.scrollTo(0, 0);
	</script>
	<%} %>
  </td></tr>
</table>
<br/><br/>
<script type="text/javascript">
  //添加收藏
  function addFavorite(bkId){
	  $.ajax({
  		url: '${ctx}/favorite/addFavorite.do',
  		type: 'post',
  		dataType: 'json',
  		data: {bookId : bkId},
  		success: function(rst, textStatus){
  	  		if(rst.result == "success"){
  	  		  alert("收藏成功");
  	  	  	}
  	  	  	if(rst.result == "added"){
  	  	  	  alert("已经收藏了该图书！");
  	  	  	}
  	  	  	if(rst.result == "error"){
  	  	  	  alert("您还没有登录，请登录！");
  	  	  	}
  		}
  	  });
  }
</script>
</body>
</html>